"use strict";
cc._RF.push(module, '65f103bCuBFj4TfUVLmDTv/', 'EventManager');
// scripts/EventManager.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
}), o.EventManager = void 0;

var a = function () {
  function e() {
    this._eventListeners = {};
  }

  return e.getInstance = function () {
    return this.instance || (this.instance = new e()), this.instance;
  }, e.destroy = function () {
    this.instance && (delete this.instance, this.instance = null);
  }, e.prototype.getEventListenersIndex = function (e, t, o) {
    for (var a = -1, n = 0; n < this._eventListeners[e].length; n++) {
      var i = this._eventListeners[e][n];

      if (i.callBack == t && (!o || i.target == o)) {
        a = n;
        break;
      }
    }

    return a;
  }, e.prototype.addEventListener = function (e, t, o) {
    if (e) {
      if (null == t) return cc.log("addEventListener callBack is nil"), !1;
      var a = {
        callBack: t,
        target: o
      };
      return null == this._eventListeners[e] ? this._eventListeners[e] = [a] : -1 == this.getEventListenersIndex(e, t, o) && this._eventListeners[e].push(a), !0;
    }

    cc.warn("eventName is empty" + e);
  }, e.prototype.setEventListener = function (e, t, o) {
    if (e) {
      if (null == t) return cc.log("setEventListener callBack is nil"), !1;
      var a = {
        callBack: t,
        target: o
      };
      return this._eventListeners[e] = [a], !0;
    }

    cc.warn("eventName is empty" + e);
  }, e.prototype.removeEventListener = function (e, t, o) {
    if (null != this._eventListeners[e]) {
      var a = this.getEventListenersIndex(e, t, o);
      -1 != a && this._eventListeners[e].splice(a, 1);
    }
  }, e.prototype.raiseEvent = function (e, t) {
    if (null != this._eventListeners[e]) {
      for (var o = [], a = 0, n = this._eventListeners[e]; a < n.length; a++) {
        var i = n[a];
        o.push({
          callBack: i.callBack,
          target: i.target
        });
      }

      for (var r = 0, s = o; r < s.length; r++) {
        (i = s[r]).callBack.call(i.target, e, t);
      }
    }
  }, e.instance = null, e;
}();

o.EventManager = a.getInstance();

cc._RF.pop();